"""
语法：
    data.squeeze(dim=n)   => 在data的n维度上降低一个维度
    data.unsqueeze(dim=n)   => 在data的n维度上添加一个维度
        n = -1 表示在最后添加一个维度
"""
import torch as t

data = t.randint(1, 100, [2, 3])
print("================= 原始数据 =================")
print(data)
print(data.shape)

print("================= data 升维 =================")
data2 = data.unsqueeze(dim=0)
print(data2)
print(data2.shape)

print("================= data 升维 =================")
data3 = data2.unsqueeze(dim=1)
print(data3)
print(data3.shape)

print("================= data 升维 =================")
data4 = data2.unsqueeze(dim=-1)
print(data4)
print(data4.shape)


print("================= data 降维 =================")
data2 = data3.squeeze(dim=0)
print(data2)
print(data2.shape)

print("================= data 降维 =================")
data1 = data2.squeeze(dim=0)
print(data1)
print(data1.shape)

print("================= data 降维 =================")
data = data1.squeeze(dim=0)
print(data)
print(data.shape)
